#ifndef CMD_NODE_H
#define CMD_NODE_H
#include <set>
#include <string>
#include <sstream>
#include <iomanip>
#include <boost/shared_ptr.hpp>
#include "cmd_executor.h"

namespace vpm
{
	namespace cmo 
	{
		struct CmdNode; 
		typedef boost::shared_ptr<CmdNode> CmdNodePtr; 

		typedef std::set<CmdNodePtr> CmdNodes;

		struct LineNodes 
		{
			CmdNodes cmdNodes; 
		};

		struct CmdNode
		{
			enum NodeType 
			{
				None,
				Root,
				KeyWord, 
				NamedValue,
				Optional,
			};

			CmdNode(NodeType type,const std::string & name, const std::string value = "", CmdNodePtr parent = CmdNodePtr());

			CmdNodePtr find_keyword(const std::string &key);

			std::string prompt_children(int indent=0);

			CmdNodes get_matched_nodes(const std::string & key);

			//test if the short key match the long key			
			bool is_match_node(const std::string & skey, const std::string & lkey);

			int index;	
			NodeType    nodeType;
			std::string nodeName; 
			std::string nodeValue;

			std::string nodeDefaultValue;

			CmdNodePtr  nodeParent;
			CmdNodes    children;			

			std::string command;
			CmdExecutorPtr executor; 			
		};		
	}
}

#endif //
    
